package com.kly.sc.api.application.enums;

import com.fqgj.exception.enums.ErrorCodeEnum;
import com.fqgj.exception.enums.MsgCodeEnum;
import com.kly.enums.TradeResultStatus;
import org.springframework.http.HttpStatus;
import org.zalando.problem.StatusType;

import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

public enum ApiResultStatus implements StatusType, MsgCodeEnum, ErrorCodeEnum {
    CONTINUE(100, "继续", ""),
    SWITCHING_PROTOCOLS(101, "切换协议", ""),
    PROCESSING(102, "处理中", ""),
    CHECKPOINT(103, "检查点", ""),
    OK(200, "确定", ""),
    CREATED(201, "已创建", ""),
    ACCEPTED(202, "已接受", ""),
    NON_AUTHORITATIVE_INFORMATION(203, "非权威信息", ""),
    NO_CONTENT(204, "无内容", ""),
    RESET_CONTENT(205, "重置内容", ""),
    PARTIAL_CONTENT(206, "部分内容", ""),
    MULTI_STATUS(207, "多种状态", ""),
    ALREADY_REPORTED(208, "已经报告", ""),
    IM_USED(226, "IM已使用", ""),
    MULTIPLE_CHOICES(300, "多项选择", ""),
    MOVED_PERMANENTLY(301, "永久移动", ""),
    FOUND(302, "已找到", ""),
    SEE_OTHER(303, "参见其他", ""),
    NOT_MODIFIED(304, "未修改", ""),
    USE_PROXY(305, "使用代理", ""),
    TEMPORARY_REDIRECT(307, "临时重定向", ""),
    PERMANENT_REDIRECT(308, "永久重定向", ""),
    BAD_REQUEST(400, "错误请求", ""),
    UNAUTHORIZED(401, "未授权", ""),
    PAYMENT_REQUIRED(402, "需要付款", ""),
    FORBIDDEN(403, "禁止", ""),
    NOT_FOUND(404, "未找到", ""),
    METHOD_NOT_ALLOWED(405, "方法不允许", ""),
    NOT_ACCEPTABLE(406, "不可接受", ""),
    PROXY_AUTHENTICATION_REQUIRED(407, "需要代理认证", ""),
    REQUEST_TIMEOUT(408, "请求超时", ""),
    CONFLICT(409, "冲突", ""),
    GONE(410, "已消失", ""),
    LENGTH_REQUIRED(411, "需要长度", ""),
    PRECONDITION_FAILED(412, "前提条件失败", ""),
    REQUEST_ENTITY_TOO_LARGE(413, "请求实体过大", ""),
    REQUEST_URI_TOO_LONG(414, "请求URI过长", ""),
    UNSUPPORTED_MEDIA_TYPE(415, "不支持的媒体类型", ""),
    REQUESTED_RANGE_NOT_SATISFIABLE(416, "无法满足请求的范围", ""),
    EXPECTATION_FAILED(417, "预期失败", ""),
    I_AM_A_TEAPOT(418, "我是个茶壶", ""),
    UNPROCESSABLE_ENTITY(422, "无法处理的实体", ""),
    LOCKED(423, "已锁定", ""),
    FAILED_DEPENDENCY(424, "依赖失败", ""),
    UPGRADE_REQUIRED(426, "需要升级", ""),
    PRECONDITION_REQUIRED(428, "需要前提条件", ""),
    TOO_MANY_REQUESTS(429, "请求过多", ""),
    REQUEST_HEADER_FIELDS_TOO_LARGE(431, "请求头字段过大", ""),
    UNAVAILABLE_FOR_LEGAL_REASONS(451, "由于法律原因不可用", ""),
    INTERNAL_SERVER_ERROR(500, "内部服务器错误", ""),
    NOT_IMPLEMENTED(501, "未实施", ""),
    BAD_GATEWAY(502, "错误网关", ""),
    SERVICE_UNAVAILABLE(503, "服务不可用", ""),
    GATEWAY_TIMEOUT(504, "网关超时", ""),
    HTTP_VERSION_NOT_SUPPORTED(505, "不支持的HTTP版本", ""),
    VARIANT_ALSO_NEGOTIATES(506, "变体也在协商", ""),
    INSUFFICIENT_STORAGE(507, "存储空间不足", ""),
    LOOP_DETECTED(508, "检测到循环", ""),
    BANDWIDTH_LIMIT_EXCEEDED(509, "超出带宽限制", ""),
    NOT_EXTENDED(510, "未扩展", ""),
    NETWORK_AUTHENTICATION_REQUIRED(511, "需要网络认证", ""),

    PARAMETER_VALIDATION_FAILED(512,"parameter validation failed","参数不能为空"),

    USER_BROWSE_IS_NULL(3001, "Browsing quantity cannot be empty", "浏览数量不能为空"),

    USER_BROWSE_LIMIT(3002, "Browsing quantity is empty", "剩余浏览次数为空"),

    USER_LIKE_LIMIT(3003, "Maximum number of likes reached", "达到最大喜欢数量"),

    USER_FIRST_CHAT_LIMIT(3004, "The number of session users has reached the limit", "会话用户数已达到限制"),

    INCORRECT_VERIFICATION_LABEL(3005, "Incorrect permission verification label", "不正确的权限验证标签"),

    UNRECOGNIZED_USER_BEHAVIOR(3006, "Unrecognized user behavior", "无法识别的用户行为"),

    CONVERSATION_MESSAGE_LIMIT(3007, "The number of single-session messages has reached the upper limit", "单会话消息数已达到上限"),

    FIRST_CONVERSATION_LIMIT(4008, "The number of message has reached the upper limit", "破冰会话数已达到上限"),

    VALID_CONVERSATION_LIMIT(3008, "The number of valid conversations has reached the upper limit", "有效会话数已达到上限"),

    DEEP_CONVERSATION_LIMIT(3009, "deep conversation limit reached", "达到深度对话限制"),

    USERID_CANNOT_BE_EMPTY(3010, "toUserId cannot be empty", "toUserId 不能为空"),

    INVALID_SOURCE_TYPE(3011,"invalid sourceType","无效的 sourceType"),

    PHONE_VERIFICATION_CODE_LIMIT(3012,"Failed to send the verification code. Please use another login method","验证码发送次数达到上限"),

    MESSAGE_FAILED_TO_SEND(3013,"message failed to send","验证码发送失败"),

    PHONE_NUMBER_IS_EMPTY(3014,"Phone number cannot be empty","电话号码为空"),

    VERIFICATION_CODE_IS_INVALID(3015,"The code has expired, please resend”","验证码错误或者无效"),

    USER_AND_MODEL_CODE_EMPTY(4003,"userCode and modelUserCode cannot be empty","userCode 和 modelUserCode 不能为空"),


    //test(1,"Browsing quantity cannot be empty","浏览数量不能为空"),
    //其他异常

    ;
    private static final Map<Integer, ApiResultStatus> STATUSES = Arrays.stream(values()).
            collect(Collectors.collectingAndThen(Collectors.toMap
                    (ApiResultStatus::getStatusCode, Function.identity()), Collections::unmodifiableMap));
    private final int code;
    private final String reason;

    private final String comment;

    public int getStatusCode() {
        return this.code;
    }

    public String getReasonPhrase() {
        return this.reason;
    }

    private ApiResultStatus(final int statusCode, final String reasonPhrase, String comment) {
        this.code = statusCode;
        this.reason = reasonPhrase;
        this.comment = comment;
    }

    @Override
    public Integer getCode() {
        return this.code;
    }

    @Override
    public String getMsg() {
        return this.reason;
    }

    @Override
    public HttpStatus getHttpStatus() {
        return null;
    }
}
